########################################################################
#  Pyfm - personal finance data-base
#  Copyright (C) 2007,8 Ehud Ben-Reuven
#  udi@benreuven.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
########################################################################
"""Convert OFX v1.x or QFX files to flat lines.
The OFX or QFX files should be located at $PYFM_DATA/ofx
The files are first converted to .xml in $PYFM_DATA/temp directory
and then to .txt files in $PYFM_DATA/flt/ofx/
"""
from ofx2xml import ofx2xml
from ofxml2flat import ofxml2flat
from lib import dirs

def pre(fname,xmlname):
	ofx2xml(fname,xmlname)

def flat(xmlname,fout,linetxt):
	ofxml2flat(xmlname,fout,linetxt)

ext='*.[oq]fx' # Files ending with .ofx or .qfx ar OK

help="""Convert OFX v1.x or QFX files to flat lines.
The OFX or QFX files should be located at $PYFM_DATA/imports/ofx
The files are first converted to XML in $PYFM_DATA/temp directory
and then to .txt files in $PYFM_DATA/flt/ofx/
For every OFX/QFX file if the appropriate .txt file already exist then no convertion is made (poor's man caching)
"""
def path(line):
	return ['ofx']

